<template>
    <div class="customer">
        <transition name="etoak">
            <div v-show="show">
                <el-card class="box-card" style="margin-left: 230px">
                    <div slot="header"  class="clearfix">
                        <h2>添加养兔技巧</h2>
                    </div>
                    <el-form :model="addForm" :rules="addFormRules"  style="width:90%"  ref="addForm" label-width="100px" class="demo-ruleForm">
                        <el-form-item label="问题" prop="name">
                            <el-input v-model="addForm.question"></el-input>
                        </el-form-item>
                        <el-form-item label="医生解答" prop="sex">
                            <el-input v-model="addForm.answer"></el-input>
                        </el-form-item>


                        <el-form-item style="text-align: center">
                            <el-button type="primary" @click="submitAddForm('addForm')">确认添加</el-button>
                            <el-button @click="resetForm('ruleForm')">重置</el-button>
                        </el-form-item>
                    </el-form>
                </el-card>
            </div>
        </transition>
    </div>
</template>
<script>
    export default {

        name:'Commodity',
        data(){
            return{
                show:false,
                coverVisiable:false,
                picsVisiable:false,
                addForm:{
                    question:"",
                    answer:""
                },
                addFormRules:{
                    question: [
                        { required: true, message: '请输入问题', trigger: 'blur' },
                    ],
                    answer: [
                        { required: true, message: '请输入答案', trigger: 'blur' },
                    ]
                }
            }
        },
        methods: {
            submitAddForm(formName) {
                // {params:{name:this.addForm.name,address:this.addForm.address,sex:}
                // this.$http.get('/customer/add?name='+this.addForm.name+'&address='+this.addForm.address).then(res => {
                this.$http.get('/raisingSkillsDO/add',{params:this.addForm}).then(res => {
                    if (res.data.code === 200) {
                        this.$message.success('成功添加养兔技巧')
                        // //添加成功后将数组设置为空
                        this.$refs[formName].resetFields()
                        // this.savepathFileList = []
                    }
                })
            }
        },
        mounted() {
            this.show = true
        }
    }
</script>
<style scoped>
    /deep/.el-dialog__headerbtn{
        top: -30px;
    }
    .etoak-enter-active,.etoak-leave-active{
        transition: all 2s;
    }
    .etoak-enter,.etoak-leave-to{
        opacity:0;
        transform: translateX(30px);
    }
</style>
